package com.ruoyi.web.controller.shopping;

import com.ruoyi.common.utils.shopping.JwtUtil;
import com.ruoyi.system.domain.shopping.Order;
import com.ruoyi.system.service.shopping.OrderService;
import com.ruoyi.system.view.common.Result;
import com.ruoyi.web.controller.shopping.common.BaseContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/xiaomi/v2/orders")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping
    public Result<List<Order>> list(){
        List<Order> orders = orderService.selectOrderList(BaseContext.getId());
        return Result.success(orders,"查询成功");
    }

    @PostMapping("/create")
    public Result create(Integer addressId, Integer[] shoppingCartIds){
        Boolean b = orderService.create(BaseContext.getId(),addressId,shoppingCartIds);
        return Result.success(null,b ? "操作成功" : "操作失败");
    }
}
